using UnityEngine;

public class ArcherJumpState : EnemyState
{
    private new Archer Enemy => (Archer)base.Enemy;

    public ArcherJumpState(Enemy enemy, string animName) : base(enemy, animName) { }

    public override void Enter()
    {
        base.Enter();
        Rb.velocity = new Vector2(Enemy.JumpVelocity.x * -Enemy.FacingDirection, Enemy.JumpVelocity.y);
    }

    public override void Update()
    {
        base.Update();
        Enemy.Anim.SetFloat("yVelocity", Rb.velocity.y);
        if (Rb.velocity.y <= 0 && Enemy.IsGroundDetected())
        {
            Enemy.SetVelocityToZero();
            StateMachine.ChangeTo(Enemy.BattleState);
        }
    }
}
